package com.victualler.core.config.permission.service.impl;

import com.victualler.core.base.service.impl.BaseServiceImpl;
import com.victualler.core.config.permission.dto.RoleGroupDto;
import com.victualler.core.config.permission.entity.RoleInfoDao;
import com.victualler.core.config.permission.repository.RoleInfoQueryRepository;
import com.victualler.core.config.permission.repository.RoleInfoRepository;
import com.victualler.core.config.permission.service.RoleInfoService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: Guoshichang
 * @Date: Create in 17:03 2018/4/5
 * @Discription:  Dict字典类型对应的服务层
 */
@Service
public class RoleInfoServiceImpl extends BaseServiceImpl<RoleInfoDao,RoleInfoRepository,RoleInfoQueryRepository> implements RoleInfoService {
    @Override
    public List<RoleInfoDao> getRoleInfoByUserId(Long userId) {
        return this.baseQueryRepository.getRoleInfoByUserId(userId);
    }

    /**
     * @author Guoshichang
     * @since 23:06 on 2018/9/18.
     * @param userId 用户id
     * @return RoleGroupDto
     * @Function  获取用户对应的 角色列表和未在列的角色列表
     */
    public RoleGroupDto getByUserId(Long userId) {
        return new RoleGroupDto(this.notInByUserId(userId),this.getRoleInfoByUserId(userId));
    }


    /**
     * @author Guoshichang
     * @since 21:12 on 2018/9/9.
     * @param userId 双
     * @return List
     * @Function
     */
    public List<RoleInfoDao> notInByUserId(Long userId) {
        return this.baseQueryRepository.notInByUserId(userId);
    }


}
